package cj.web.activity.dao;
/*
 *  
 *  
*/
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.activity.domain.Prize;

/**
 * 
 * @author 
 *
 */
@DAO
public interface PrizeDAO{
    
    @SQL("select * from Prize where id=:1")
    Prize queryById(int id);
    
    @SQL("select count(1) from Prize "
    		+ "where id =:1 "
    		+ "and StartAT < date_format(:2,'%Y-%m-%d %H:%i:%s') "
    		+ "and EndAT > date_format(:2,'%Y-%m-%d %H:%i:%s')")
    int queryByIdAndDate(int id,String date);
    
    @SQL("INSERT INTO Prize ("
    		        		+ "ID,"
			        		+ "ActiveName,"
			        		+ "ActiveNo,"
			        		+ "ActivePic,"
			        		+ "ActiveEndPic,"
			        		+ "StartAT,"
			        		+ "EndAT,"
			        		+ "ActiveDescription,"
			        		+ "AuditStatus,"
			        		+ "AuditAT,"
			        		+ "SharePicPath,"
			        		+ "ShareContent,"
			        		+ "ShareUrl,"
			        		+ "CreateAT,"
			        		+ "Status,"
			        		+ "Remark"
							+") VALUES ("
							+ ":t.ID,"
							+ ":t.ActiveName,"
							+ ":t.ActiveNo,"
							+ ":t.ActivePic,"
							+ ":t.ActiveEndPic,"
							+ ":t.StartAT,"
							+ ":t.EndAT,"
							+ ":t.ActiveDescription,"
							+ ":t.AuditStatus,"
							+ ":t.AuditAT,"
							+ ":t.SharePicPath,"
							+ ":t.ShareContent,"
							+ ":t.ShareUrl,"
							+ ":t.CreateAT,"
							+ ":t.Status,"
							+ ":t.Remark"
					+")")
    void create(@SQLParam("t") Prize Prize);
	
	@SQL("UPDATE Prize SET "
		    		    						    			        + "ActiveName=:t.ActiveName,"
		        					    			        + "ActiveNo=:t.ActiveNo,"
		        					    			        + "ActivePic=:t.ActivePic,"
		        					    			        + "ActiveEndPic=:t.ActiveEndPic,"
		        					    			        + "StartAT=:t.StartAT,"
		        					    			        + "EndAT=:t.EndAT,"
		        					    			        + "ActiveDescription=:t.ActiveDescription,"
		        					    			        + "AuditStatus=:t.AuditStatus,"
		        					    			        + "AuditAT=:t.AuditAT,"
		        					    			        + "SharePicPath=:t.SharePicPath,"
		        					    			        + "ShareContent=:t.ShareContent,"
		        					    			        + "ShareUrl=:t.ShareUrl,"
		        					    			        + "CreateAT=:t.CreateAT,"
		        					    			        + "Status=:t.Status,"
		        					    			        + "Remark=:t.Remark"
		        						+ " WHERE ID=:t.ID")
    void update(@SQLParam("t") Prize Prize);
    
    @SQL("UPDATE Prize SET delete_flag=0 WHERE id=:id")
    void deleteById(String id);
}